package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.Cabinrule;
import com.ktgj.flight.service.ICabinruleService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 舱位退改签Controller
 * 
 * @author ruoyi
 * @date 2021-08-30
 */
@Api(tags = "舱位退改签")
@ControllerAdvice
@RestController
@RequestMapping("/cabinrule")
public class CabinruleController extends BaseController
{
    @Autowired
    private ICabinruleService cabinruleService;

    /**
     * 查询舱位退改签列表
     */
    //@PreAuthorize(hasPermi = "flight:cabinrule:list")
    @ApiOperation(value = "查询舱位退改签列表")
    @GetMapping("/list")
    public TableDataInfo list(Cabinrule cabinrule)
    {
        startPage();
        List<Cabinrule> list = cabinruleService.selectCabinruleList(cabinrule);
        return getDataTable(list);
    }

    /**
     * 导出舱位退改签列表
     */
    //@PreAuthorize(hasPermi = "flight:cabinrule:export")
    @ApiOperation(value = "导出舱位退改签列表")
    @Log(title = "舱位退改签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Cabinrule cabinrule) throws IOException
    {
        List<Cabinrule> list = cabinruleService.selectCabinruleList(cabinrule);
        ExcelUtil<Cabinrule> util = new ExcelUtil<Cabinrule>(Cabinrule.class);
        util.exportExcel(response, list, "舱位退改签数据");
    }

    /**
     * 获取舱位退改签详细信息
     */
    //@PreAuthorize(hasPermi = "flight:cabinrule:query")
    @ApiOperation(value = "获取舱位退改签详细信息")
    @GetMapping(value = "/{ruleid}")
    public AjaxResult getInfo(@PathVariable("ruleid") Long ruleid)
    {
        return AjaxResult.success(cabinruleService.selectCabinruleById(ruleid));
    }

    /**
     * 新增舱位退改签
     */
    //@PreAuthorize(hasPermi = "flight:cabinrule:add")
    @ApiOperation(value = "新增舱位退改签")
    @Log(title = "舱位退改签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Cabinrule cabinrule)
    {
        return toAjax(cabinruleService.insertCabinrule(cabinrule));
    }

    /**
     * 修改舱位退改签
     */
    //@PreAuthorize(hasPermi = "flight:cabinrule:edit")
    @ApiOperation(value = "修改舱位退改签")
    @Log(title = "舱位退改签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Cabinrule cabinrule)
    {
        return toAjax(cabinruleService.updateCabinrule(cabinrule));
    }

    /**
     * 删除舱位退改签
     */
    //@PreAuthorize(hasPermi = "flight:cabinrule:remove")
    @ApiOperation(value = "删除舱位退改签")
    @Log(title = "舱位退改签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ruleids}")
    public AjaxResult remove(@PathVariable Long ruleids)
    {
        return toAjax(cabinruleService.deleteCabinruleById(ruleids));
    }
}
